﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManageData
{
    internal class 保存点
    {
        void MyMethod()
        {
            using (var db = new BasicDbContext())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    db.Add(new BasicEntity());
                    db.SaveChanges();
                    trans.CreateSavepoint("SavePoints");

                    db.Add(new BasicEntity());
                    db.SaveChanges();
                    trans.RollbackToSavepoint("SavePoints");

                    trans.Commit();
                }

            }

        }
    }
}
